package com.jlnk.androidfmc.view;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;

import com.jlnk.androidfmc.MainActivity;
import com.jlnk.androidfmc.MessageActivity;
import com.jlnk.androidfmc.R;
import com.jlnk.androidfmc.fragment.ConsultFragment;
import com.jlnk.androidfmc.fragment.HotNewFragment;
import com.jlnk.androidfmc.fragment.fragments.MessageFragment;
import com.jlnk.androidfmc.fragment.fragments.SchoolFragment;

public class ConsultDetail extends AppCompatActivity {

    private EditText editTextName, editTextContact, editTextConsultation;
    private Button buttonSubmit;
    private boolean consultationContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.consult_detail);

        // Initialize views
        editTextName = findViewById(R.id.editTextName);
        editTextContact = findViewById(R.id.editTextContact);
        editTextConsultation = findViewById(R.id.editTextConsultation);
        buttonSubmit = findViewById(R.id.buttonSubmit);

        // Set up the submit button click listener
        buttonSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                submitConsultation();
            }
        });
    }

    // ConsultDetail.java
    private void submitConsultation() {
        String consultation = editTextConsultation.getText().toString();
        if (!consultation.isEmpty()) {
            Intent resultIntent = new Intent();
            resultIntent.putExtra("CONSULTATION_CONTENT", consultation);
            setResult(RESULT_OK, resultIntent); // 设置结果
            Toast.makeText(this, "提交成功！", Toast.LENGTH_SHORT).show(); // 提示用户
            finish(); // 结束当前活动
        } else {
            Toast.makeText(this, "咨询内容不能为空！", Toast.LENGTH_SHORT).show();
        }
    }
}